package org.txazo.blog.web.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.txazo.blog.web.action.base.BaseAction;

/**
 * CommonAction - 公共页面
 * 
 * @author Tu XiaoZhou
 * @since 2013-09-03
 * 
 */
@Controller
@Scope("session")
@Namespace("/common")
public class CommonAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	private String url;

	@Action(value = "ip", results = { @Result(name = SUCCESS, location = "/common/ip.jsp") })
	public String ip() {
		return SUCCESS;
	}

	@Action(value = "error", results = { @Result(name = SUCCESS, location = "/common/error.jsp") })
	public String error() {
		return SUCCESS;
	}

	@Action(value = "exception", results = { @Result(name = SUCCESS, location = "/common/exception.jsp") })
	public String exception() {
		request.setAttribute("back", url);
		return SUCCESS;
	}

	/** 拒绝访问 */
	@Action(value = "status403", results = { @Result(name = SUCCESS, location = "/common/403.jsp") })
	public String status403() {
		return SUCCESS;
	}

	/** 资源不存在 */
	@Action(value = "status404", results = { @Result(name = SUCCESS, location = "/common/404.jsp") })
	public String status404() {
		return SUCCESS;
	}

	@Action(value = "status405", results = { @Result(name = SUCCESS, location = "/common/405.jsp") })
	public String status405() {
		return SUCCESS;
	}

	public void setUrl(String url) {
		this.url = url;
	}

}
